import instance from '@/utils/request'
enum MethodEnum{
    get="get",
    post="post",
    delete="delete",
    put="put"

}
interface OptionsType{
    url:string
    method?:MethodEnum
    params?:Object
    data?:Object
    headerType?:string
    responseType?:any
}
const request=(options:OptionsType)=>{
    const {url,method,params,data,headerType,responseType}=options
    return instance({
        url,
        method,
        params,
        data,
        headers:{
            'Content-Type':headerType
        },
        responseType
    })
} 
export default{
    get(options:OptionsType){
        return request({...options,method:MethodEnum.get})
    },
    post(options:OptionsType){
        return request({...options,method:MethodEnum.post})
    },
    put(options:OptionsType){
        return request({...options,method:MethodEnum.put})
    },
    delete(options:OptionsType){
        return request({...options,method:MethodEnum.delete})
    }
}      
